//logs.js
// const util = require('../../utils/util.js')
let app = getApp();
Page({
  data: {
    goodsData: {},
    indicatorDots: true,
    vertical: true,
    autoplay: false,
    interval: 3000,
    duration: 500,
    swiperImgs:[],
    detailImgs:[]
  },
  onLoad(option){
    let id = option.id;
    wx.showLoading({
      title: '请稍等...',
    })
    app.post("productDetails",{id:id})
    .then((res)=>{
      wx.hideLoading();
      if(res.code == 200){
        let imgs = res.data.goodsImgs;
        let detailImgs = [];
        let swiperImgs = [];
        for (let item of imgs){
          if (item.attaType == "MAIN"){
            swiperImgs.push(item);
          }else{
            detailImgs.push(item);
          }
        }
        this.setData({
          goodsData: res.data,
          swiperImgs,
          detailImgs
        });
      }else{
        app.toast(res.message);
      }
    }).catch((e) => {
      console.log(e);
      wx.hideLoading();
      app.toast("网络或服务器错误～");
    })
  },
  changeIndicatorDots (e) {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  changeAutoplay(e) {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },
  intervalChange(e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange(e) {
    this.setData({
      duration: e.detail.value
    })
  },
})
